class MRUQueue(object):

    def __init__(self, n):
        """
        :type n: int
        """
        self.p = [i for i in range(1, n + 1)]


    def fetch(self, k):
        """
        :type k: int
        :rtype: int
        """
        val = self.p[k - 1]
        self.p = self.p[: k - 1] + self.p[k:] + [self.p[k - 1]]
        return val
